const { exec } = require('child_process');
import path from 'path'

import { moveReleaseFileToDist } from './files'

const runFile = 'run.sh'
export const runPy = async (filepath) => {
  const f = path.resolve(filepath, runFile)
  console.log("run file===>", f)
  return new Promise((res,rej) => {
    exec(`cd ${filepath} && ./${runFile}`, (err, stdout, stderr) => {
      console.log(stdout, stderr)
      if (err) {
        rej(stderr)
      } else {
        res(stdout)
        console.log('存在  topic文件夹', filepath)
        moveReleaseFileToDist(filepath)
      }
    })
  })
}